@ \title{The control flow of a HTTP connection}

Copyright \copyright{}~2019 Ariadne Devos

This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version~3 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with this program.  If not, see
\textless{}http://www.gnu.org/licenses/\textgreater{}.

\newcommand{\rfc}[4]{(RFC #1, #2 #3, p.~#4)}

The underlying transport is ignored; it is assumed to be a mostly reliable
transport, except for the occassional errors. This document computes a control
flow graph between different states, and the source code to implement it.

TODO: split in header and other documents

<<*>>=
<<S2 method enum>>

@ \section{Common grammar definitions}

Adapted from \rfc{2616}{2.2}{Basic Rules}{15}.

\begin{description}
\item[CHAR] ASCII character: octet 0 - 127
\item[CTL] ASCII control characters: octet 0 .. 31, 127
\item[seperators] any of {}[]()\textless\textgreater@/\textbackslash@,:;?=", space, horizontal
  tab
\item[token] a sequence of any CHAR, except CTL and seperators
\end{description}

\section{The request line}

From \rfc{2616}{5.1}{Request-Line}{35}:

\begin{quote}
Request-Line = Method SP Request-URI SP HTTP-Version CRLF
\end{quote}

The method specifies what must be done with the resource, e.g. GET fetches
the resource and DELETE removes it. HTTP/1.1 defines the following
\rfc{2616}{5.1.1}{Method}{36}:

<<HTTP/1.1 method names>>=
S2_HTTP_METHOD_OPTIONS,
S2_HTTP_METHOD_GET,
S2_HTTP_METHOD_HEAD,
S2_HTTP_METHOD_POST,
S2_HTTP_METHOD_PUT,
S2_HTTP_METHOD_DELETE,
S2_HTTP_METHOD_TRACE,
S2_HTTP_METHOD_CONNECT,

@ There is also a thing called WebDAV, defined in the proposed standard
RFC 2518. It is there described as an extension to HTTP/1.1 for `remote
web content authoring operations.' It contemplates authors, locking and
editing, but its implementation is left out-of-scope to s2 for the moment.

<<WebDAV method names>>=
S2_WEBDAV_METHOD_PROPFIND,
S2_WEBDAV_METHOD_PROPPATCH
S2_WEBDAV_METHOD_MKCOL,
S2_WEBDAV_METHOD_COPY,
S2_WEBDAV_METHOD_MOVE,
S2_WEBDAV_METHOD_LOCK,
S2_WEBDAV_METHOD_UNLOCK,

@ Now a enum can be defined for this collection of methods.

<<S2 method enum>>=
enum s2_http_method {
	<<HTTP/1.1 method names>>,
	<<WebDAV method names>>,
}
